package letterbox;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.util.HashSet;
import java.util.Set;
import javax.swing.JPanel;

/**
 *
 * @author Mikael Kohlmyr
 */
public class Screen extends JPanel{
    private Set<Cell> cells;

    public Screen(){
        cells = new HashSet<Cell>();
    }

    public void configure(){
        repaint();
    }

    public void test(){
        Crossword c = CrosswordExample.getPuzzle();
        this.cells = c.getCells();
    }

    @Override
    public void paintComponent(Graphics g){
        g.setColor(Color.BLACK);
        g.fillRect(0, 0, Window.WIDTH, Window.HEIGHT);
        System.out.println(this.cells.size());
        for(Cell cell : this.cells){
            g.setColor(Color.WHITE);
            g.fillRect(cell.getX()*cell.WIDTH, cell.getY()*cell.HEIGHT, cell.WIDTH, cell.HEIGHT);
            g.setColor(Color.BLACK);
            g.drawRect(cell.getX()*cell.WIDTH, cell.getY()*cell.HEIGHT, cell.WIDTH, cell.HEIGHT);
            g.setFont(new Font(Font.SERIF, Font.PLAIN , 12));
            g.drawString(String.valueOf(cell.getAnswer()), cell.getX()*cell.WIDTH + 12, cell.getY()*cell.HEIGHT + 16);
        }
        
    }
}
